<script type="text/javascript" src="/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="/yui/container/container-min.js"></script>
<script type="text/javascript" src="/yui/yahoo/yahoo.js"></script> 
<script type="text/javascript" src="/yui/event/event.js"></script> 
<script type="text/javascript" src="/yui/connection/connection-min.js"></script> 

<div id="loading" style="position: absolute; left: 400px; top: 100px; z-index: 99; margin: auto; visibility: hidden">
	<img src="/app/default/www/images/loading.gif" />
</div>
<div id="kapila">
</div>
<div id="ajakdib">
</div>

<script>
{literal}

	var timeout = 900000; // 15 mins
	
	function getAjak()
	{
		var div = document.getElementById("kapila"); 
		var disptimeout = timeout / ( 60000 ) 
		div.innerHTML = disptimeout;
				
		timeout = timeout + 300000; //+ 5 mins
		showLoading(true);
		var getAssignedSuccess = function (o) {
			if (o.responseText !== undefined) { 
				var div = document.getElementById('ajakdib'); 
				div.innerHTML = o.responseText;
			}
			showLoading(false);
			if( document.getElementById("userid").value.length ){
				setTimeout ( "getAjak()", timeout );
			}
		} 
		var getAssignedFailure = function (o) { 
			if (o.responseText !== undefined) { 
				alert(o.statusText);
			} 
			showLoading(false);
		}
		var ajaxGetAssigned = { 
			success:getAssignedSuccess, 
			failure:getAssignedFailure, 
			argument: {}
		}; 
		
		var request = YAHOO.util.Connect.asyncRequest('GET', '/test/getajak', ajaxGetAssigned); 
	}
	
	function showLoading(show)
	{
		if (show) {
			document.getElementById("loading").style.visibility = "visible";
		} else {
			document.getElementById("loading").style.visibility = "hidden";
		}
	}
	
	setTimeout ( "getAjak()", timeout );

{/literal}
</script>